package com.zhoux.activity;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.repository.Deployment;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.runtime.ProcessInstance;
import org.junit.Test;

public class Flow {
	ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
	@Test
	public void deployFlow(){
		
		Deployment deployment = processEngine.getRepositoryService()
				.createDeployment().name("helloworld")
				.addClasspathResource("diagrams/helloworld.bpmn").addClasspathResource("diagrams/helloworld.bpmn")
				.deploy();
		System.out.println(deployment.getId());
		System.out.println(deployment.getName());
	}
	@Test
	public void flowStart(){
		RuntimeService runtimeService=processEngine.getRuntimeService();
		ProcessInstance processInstance=runtimeService.startProcessInstanceById("HelloWorldKey");
		System.out.println(processInstance.getId());
		System.out.println(processInstance.getName());
		
		RepositoryService repositoryService=processEngine.getRepositoryService();
		
		ProcessDefinition processDefinition=repositoryService.getProcessDefinition(processInstance.getId());
		System.out.println(processDefinition.getId());
		System.out.println(processDefinition.getName());
		
	}
}
